package org.action.controller;



import org.action.domain.entity.Action;
import org.action.service.IActionService;
import org.common.util.Result;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zafkiel
 * @since 2025-06-21
 */
@RestController
@RequestMapping("/action")
public class ActionController {
    @Autowired
    private IActionService iActionService;


    @GetMapping(("/list"))
    //获取活动的list数据
    public Result getAllActions() {
        return Result.success("获取活动操作成功",iActionService.getaAllActionlist());
    }

    //根据id获取活动数据
    @GetMapping("/{id}")
    public Result getActionById(@PathVariable Integer id) {
        return Result.success("获取活动操作成功",iActionService.getActionDetailsById(id));
    }

    @GetMapping("/getActionById/{id}")
    public Result getActionByIds(@PathVariable("id") Integer id) {
        return Result.success("获取活动操作成功",iActionService.getById(id));
    }

    //添加活动
    @PostMapping("/addAction")
    public Result addAction(@RequestBody Action actionListAdd) {
        System.out.println(actionListAdd);
        iActionService.save(actionListAdd);
        return  Result.success("添加成功");
    }

}
